/*
 *    This file is part of SSHTunneler.
 *
 *    Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
 *
 *    SSHTunneler is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    SSHTunneler is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with SSHTunneler.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package sshtunneler.library;

public class Tunnel {
	private String remoteServer;
	private int remotePort;
	private int localPort;

	public Tunnel(String remoteServer, int remotePort, int localPort) {
		this.remoteServer = remoteServer;
		this.remotePort = remotePort;
		this.localPort = localPort;
	}

	public String getRemoteServer() {
		return this.remoteServer;
	}

	public int getRemotePort() {
		return this.remotePort;
	}

	public int getLocalPort() {
		return this.localPort;
	}

	public void setRemoteServer(String remoteServer) {
		this.remoteServer = remoteServer;
	}

	public void setRemotePort(int remotePort) {
		this.remotePort = remotePort;
	}

	public void setLocalPort(int localPort) {
		this.localPort = localPort;
	}

	@Override
	public int hashCode() {
		int hash = 3;
		hash = 59
				* hash
				+ (this.remoteServer != null ? this.remoteServer.hashCode() : 0);
		hash = 59 * hash + this.remotePort;
		hash = 59 * hash + this.localPort;
		return hash;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (this.getClass() != obj.getClass()) {
			return false;
		}
		final Tunnel other = (Tunnel) obj;
		if ((this.remoteServer == null) ? (other.remoteServer != null)
				: !this.remoteServer.equals(other.remoteServer)) {
			return false;
		}
		if (this.remotePort != other.remotePort) {
			return false;
		}
		if (this.localPort != other.localPort) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return this.getLocalPort() + "->" + this.getRemoteServer() + ":"
				+ this.getRemotePort();
	}
}
